<template>
  <div>
    <div class="content_padding">
      <div class="container" style="position: fixed; top: 0;left: 0;">
        <span class="staffTitle">维保记录详情</span>
        <div class="btn">
          <el-button type="text" icon="icon iconfont iconfanhui" @click="returnPage">返回</el-button>
        </div>
      </div>

      <div class="device_info two-columns">
        <div class="title">设备基本信息</div>
        <div class="basic_info" style="margin-top: 10px;">
          <!-- 左侧信息 -->
          <div class="left-column">
            <div class="info_box">
              <span class="txt">设备类型：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ formData.deviceTypeName }}</span>
            </div>
            <div class="info_box">
              <span class="txt">设备规格：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ formData.model }}</span>
            </div>
            <div class="info_box">
              <span class="txt">设备来源：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ formData.deviceSource }}</span>
            </div>
          </div>

          <!-- 右侧信息 -->
          <div class="right-column">
            <div class="info_box">
              <span class="txt">标段：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ formData.bidSection }}</span>
            </div>
            <div class="info_box">
              <span class="txt">进场编号：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ formData.mobilizationSerialNumber }}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="wire"></div>

      <div class="device_info two-columns">
        <div class="title">维养记录信息</div>

        <div class="basic_info">
          <!-- 左侧信息 -->
          <div class="left-column">
            <div class="info_box">
              <span class="txt">维修/保养：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ form.type == 0 ? "维护" : "保养" }}</span>
            </div>
            <div class="info_box">
              <span class="txt">维养单位：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ form.unit }}</span>
            </div>
            <div class="info_box">
              <span class="txt">维养结论：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ form.approvalResults }}</span>
            </div>
            <div class="info_box">
              <span class="txt">检定证书编号：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ form.report }}</span>
            </div>
          </div>

          <!-- 右侧信息 -->
          <div class="right-column">
            <div class="info_box">
              <span class="txt">维保时间：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ form.maintenanceTime }}</span>
            </div>
            <div class="info_box">
              <span class="txt">登记人：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ form.repairman }}</span>
            </div>
            <div class="info_box">
              <span class="txt">登记时间：</span>
              <span class="element_color">&nbsp;</span>
              <span class="text-val">{{ form.createTime }}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="wire"></div>

      <div class="device_info two-columns">
        <div class="title">维养技术资料</div>
        <div style="padding: 0 100px 30px 100px; margin-top: 30px;">
          <el-table :data="exitRecord" border size="small" style="width: 100%">
            <el-table-column prop="name" label="文件名称"></el-table-column>
            <el-table-column prop="size" label="文件大小"></el-table-column>
            <el-table-column prop="from" label="创建人"></el-table-column>
            <el-table-column prop="action" label="操作"></el-table-column>
          </el-table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import constants from "../../../util/constants";

export default {
  name: "MatainDetail",
  data() {
    return {
      formData: {
        deviceType: "",
        bidSection: "",
        mobilizationSerialNumber: "",
        model: "",
        deviceSource: ""
      },
      form: {
        type: "",
        startTime: "",
        endTime: "",
        repairman: "",
        approvalResults: "",
        createTime: "",
        nextTime: "",
        unit: "",
        report: ""
      },
      exitRecord: []
    }
  },

  methods: {
    returnPage() {
      this.$parent.$data.showPage = 0;
    },

    getMatainDetail(data) {
      data.row.deviceTypeName = constants.DEVICE_TYPE_LIST[data.row.deviceType];
      this.formData = data.row;
      let detailsInfo = data.rowData;
      for (let key in detailsInfo) {
        if (detailsInfo.maintenanceTime) {
          detailsInfo.maintenanceTime = detailsInfo.maintenanceTime.slice(0, 10);
        }
        if (detailsInfo.createTime) {
          detailsInfo.createTime = detailsInfo.createTime.slice(0, 10);
        }
      }
      this.form = detailsInfo;
    }
  }
}
</script>

<style scoped lang="scss">
.content_padding {
  padding: 20px;
  box-sizing: border-box;
  margin-top: 20px;

  .device_info {
    margin-top: 30px;

    .upload-pic {
      margin-left: 60px;
      padding: 30px 0 0 60px;
      display: flex;

      span {
        font-size: 14px;
        margin-right: 20px;
        margin-top: 4px;
      }
    }

    &.two-columns {
      .textarea-wrap {
        margin-left: 60px;
        padding: 30px 20px 0 0;

        span {
          margin-right: 0;
          margin-top: 0;
        }

        .txt {
          font-size: 14px;
          width: 130px;
          display: inline-block;
          text-align: right;
        }

        .textarea {
          display: inline-block;
          width: 1125px;
          height: 80px;
          margin-left: 20px;
          border-radius: 4px;
          background: #f1f1f1;
        }
      }

      .left-column {
        margin-left: 20px;
      }

      .left-column,
      .right-column {
        width: 48%;
      }
    }

    .title {
      width: 100%;
      font-weight: bold;
      line-height: 50px;
      display: inline-block;
      border-bottom: 1px solid rgb(236, 236, 236);
    }

    .basic_info {
      display: flex;
      flex-wrap: wrap;

      .info_box {
        margin-right: 30px;
        margin-top: 24px;
        display: flex;
        align-items: center;

        &.image-wrap {
          flex-direction: column;
          align-items: normal;

          .pic-wrap {
            margin-left: 185px;
            margin-top: -40px;
            width: 500px;
          }

          .txt {
            line-height: 42px;
          }
        }

        .txt {
          font-size: 14px;
          width: 174px;
          display: inline-block;
          text-align: right;
        }

        .element_color {
          color: #f44336;
          font-size: 12px;
          margin-right: 12px;
        }

        .text-val {
          font-size: 14px;
          color: #333333;
          background: #f5f5f5;
          height: 42px;
          line-height: 42px;
          padding-left: 16px;
          border-radius: 4px;
          display: inline-block;
          width: 400px;
        }

        .input_width {
          height: 42px;
          display: flex;
          align-items: center;
        }
      }
    }
  }
}

.wire {
  width: 100%;
  height: 1px;
  background: rgb(236, 236, 236);
  margin-top: 30px;
}

.el-button--text >>> .iconfanhui,
.el-button--text >>> .iconfasongtijiao {
  margin-right: 4px;
  font-size: 18px;
  vertical-align: -2px;
}
</style>
